import * as excel from '@/vendor/Export2Excel'

export function exportDeptNotice (dataList) {
  let header = ['序号', '部门', '公告标题', '通知人数', '已读人数', '未读人数', '发布时间']
  let key = ['index', 'deptName', 'noticeTitle', 'noticeCount', 'yiReadCount', 'weiReadCount', 'createTime']
  let result = dataList.map(x => key.map(k => x[k]))
  result.forEach((x, i) => (x[0] = i + 1))

  excel.export_json_to_excel({
    title: '部门公告情况',
    header: header,
    data: result,
    filename: '部门公告情况'
  })
}

export function exportUserNotice (dataList) {
  let header = ['序号', '姓名', '部门', '公告标题', '阅读状态', '发布时间']
  let key = ['index', 'realname', 'deptName', 'noticeTitle', 'readStatus', 'createTime']
  let result = dataList.map(x => key.map(k => x[k]))
  result.forEach((x, i) => (x[0] = i + 1))

  excel.export_json_to_excel({
    title: '个人公告情况',
    header: header,
    data: result,
    filename: '个人公告情况'
  })
}
